export class UnOrderMultiMap<T, K> extends Map<T, K[]> {

    add(t: T, k: K) {
        let list = this.get(t) as K[];
        if (!list) {
            list = [];
            this.set(t, list);
        }
        list.push(k);
    }

    remove(t: T, k: K) {
        let list = this.get(t) as K[];
        if (!list) {
            return false;
        }
        let index = list.indexOf(k);
        if (index == -1) {
            return false;
        }
        list.splice(index, 1);
        if (list.length == 0) {
            this.delete(t);
        }
        return true;
    }

}